using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Suucha.Adsi.Configuration
{
    public class AdsiSettingsCollection : ConfigurationElementCollection
    {

        public void ForEach(Action<AdsiSettings> action)
        {
            for (int i = 0; i < Count; i++)
            {
                action(Get(i));
            }
        }

        public AdsiSettings Get(int index)
        {
            return (AdsiSettings)base.BaseGet(index);
        }

        public AdsiSettings Get(string name)
        {
            return BaseGet(name) as AdsiSettings;
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new AdsiSettings();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            AdsiSettings adsiSettings = (AdsiSettings)element;
            return adsiSettings.Name;
        }
    }
}
